<include file="Public/common" />
<block name="content">
    <style>
        th,td{text-align: center;}
        .row-2{
            padding: 0px 10px;
        }
        .form-group{
            padding-right: 50px!important;
        }
        .width-157{
            width: 157px!important;
        }
        .pull-right{
            margin-right: 14px!important;
        }
    </style>
    <div class="page-header"><h1><i class="fa fa-home"></i> 首页 &gt; 会员管理 &gt; 会员列表</h1></div>

    <div class="col-xs-12">

        <div class="tab-content">
            <div class="row" >
                <form action="" class="form-inline " method="post" style="margin-left:10px;" >
                    <div class="row-2" >
                        <div class="form-group">
                            <label for="visitor_name">持卡人:</label>
                            <input type="text" class="" name="visitor_name" id="visitor_name" value="{$post.visitor_name}">
                        </div>
                        <div class="form-group">
                            <label for="card_num">卡号:</label>
                            <input type="text" class="" name="card_num" id="card_num" value="{$post.card_num}">
                        </div>
                        <div class="form-group">
                            <label for="source_type">来源属性:</label>
                            <select id="source_type" name="source_type" class="width-157">
                                <option value="0">请选择</option>
                                <option value="1" <if condition="$post.source_type eq 1">selected</if> >直营门店</option>
                                <option value="2" <if condition="$post.source_type eq 2">selected</if> >分销商</option>
                            </select>
                        </div>
                     </div>
                    <div class="row-2" >
                        <div class="form-group">
                            <label for="order_id">订单号:</label>
                            <input type="text" class="" name="order_id" id="order_id" value="{$post.order_id}">
                        </div>
                        <div class="form-group">
                            <label for="visitor_phone">电话:</label>
                            <input type="text" class="" name="visitor_phone" id="visitor_phone" value="{$post.visitor_phone}">
                        </div>
                        <div class="form-group">
                            <label for="entry_time">下单时间:</label>
                            <input type="date" class="" name="entry_time" id="entry_time" value="{$post.entry_time}">
                        </div>

                        <button type="submit" class="btn btn-primary">查询</button>
                    </div>
                    <div class="row-2" >
                          <a href="{:U('add_visitor')}" class="btn btn-primary btn-xs pull-right">添加</a>
                          <a href="{:U('visitorExportExcel')}" class="btn btn-primary btn-xs pull-right">导出</a>
                    </div>
                </form>
            </div>
        </div>

        <div class="tabbable">
  <!--           <ul class="nav nav-tabs padding-12 tab-color-blue background-blue" id="myTab">
                <li class="active"><a href="{:U('Rule/admin_user_list')}">员工列表</a></li>
                <li><a href="{:U('Rule/add_admin')}">添加员工</a></li>
            </ul> -->
            <div class="tab-content">
                <table class="table table-striped table-bordered table-hover table-condensed">
                    <tr>
                        <th>姓名</th>
                        <th>性别</th>
                        <th>证件号</th>
                        <th>电话</th>
                        <th>卡号</th>
                        <th>来源属性</th>
                        <th>消费总额</th>
                        <th>累计积分</th>
                        <th>消费次数</th>
                        <th>创建时间</th>
                        <th>操作</th>
                    </tr>
                    <foreach name="list" item="v">
                        <tr>
                            <td>{$v['visitor_name']}</td>
                            <td><if condition="$v['visitor_sex'] eq 1">男<else/>女</if></td>
                            <td>{$v['documents_num']}</td>
                            <td>{$v['visitor_phone']}</td>
                            <td>{$v['card_num']}</td>
                            <!-- <td>{$v['source_type']}</td> -->
                            <td><if condition="$v['source_type'] eq 1">直营门店<else/>分销商</if></td>
                            <td>{$v['total_consumption']}</td>
                            <td>{$v['total_score']}</td>
                            <td>{$v['consume_num']}</td>
                            <td>{$v['entry_time']|date='Y-m-d',###}</td>
                            <td>
                                <a href="{:U('Visitor/add_visitor',array('id'=>$v['visitor_id']))}" class="btn btn-xs btn-primary ">编辑</a>
                                <if condition="$v['visitor_status'] eq 1">
                                    <a href="javascript:changeVisitorStatus('{$v['visitor_id']}',0)" class="btn btn-xs btn-warning">锁定</a>
                                    <else/>
                                    <a href="javascript:changeVisitorStatus('{$v['visitor_id']}',1)" class="btn btn-xs btn-primary">开通</a>
                                </if>
                            </td>
                        </tr>
                    </foreach>
                    <tr>
                        <td colspan="12">
                            <!--分页样式-->
                            <ul class="pagination">
                                {$show}
                            </ul>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    <script>
        function changeVisitorStatus(uid,status) {
            var operation='开通';
            if(status==0){
                operation='锁定';
            }
            //询问框
            layer.confirm('确定'+operation+'此用户吗?', {
                btn: ['确定','取消'] //按钮
            }, function(){
                $.ajax({
                    url:'{:U("Visitor/changeVisitorStatusById")}',
                    dataType:"json",
                    type:'POST',
                    cache:false,
                    data:{uid:uid,status:status},
                    success: function(data) {
                        layer.msg(data.msg);
                        if (data.status==1) {
                            setTimeout(function () {
                                location.reload();
                            },1500);
                        }
                    }
                });
            });


        }
    </script>
</block>
